$(function () {
var bt=$('#bt');
var regex=/^([\w]+)(\.[\w]+)*@([\w\-]+\.){1,5}([A-Za-z]){2,4}$/;
bt.click(function() {       
    var name=$("#name").val();
    var email=$("#email").val();
    var messages=$("#messages").val();
    if( jQuery.trim(name)=='')
    {
      alert("Name is required!");
      return false;
    }      
    if( jQuery.trim(email)=='')
    {
      alert("Email is required!");
      return false;
    }   
    else
    {
       if(!regex.test(email))
       {
         alert("Email is not correct.");
         return false;
       }
    }    
    if( jQuery.trim(messages)=='')
    {
      alert("Messages is required!");
      return false;
    }         
     
    var form=$("#form1");
    form.ajaxForm({success:function(){
     alert("Thanks for your inquiry we will deal with it as soon as possible.");
     location.replace(location.href);
    }});     
    form.submit();     
    bt.attr("disabled",true);
   }); 
});

